package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by Administrater on 2015/12/8.
 */
public class UpdateNickOrSignTask extends CouponHttpBaseTask {
    private String mUserSign;
    private String mNickName;
//    private String area;
    private boolean mSex;

    public UpdateNickOrSignTask(String userSign, String nickName, boolean sex) {
        super(TaskType.UPDATE_NICKNAME_OR_SIGN_TASK);
        mUserSign = userSign;
//        area = area;
        mNickName = nickName;
        mSex = sex;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.UPDATE_NICKNAME_OR_SIGN_REQUEST);
            JSONObject json = new JSONObject();
            json.put("userSign", mUserSign);
            json.put("nickName", mNickName);
            json.put("sex", mSex);
//            json.put("area", area);
            request.setData(json.toString());
            request.setApiNo(ApiNo.UPDATE_NICKNAME_OR_SIGN);
            addRequest(request);
        }
    }
}
